runSafeSuspendCatching

inline suspend fun <R> runSafeSuspendCatching(block: () -> R): Result<R>

Runs a suspending function block safely, catching any exceptions that occur during its execution. Returns a Result indicating success or failure of the function.

Return

a Result indicating success (Result.success) or failure (Result.failure) of the function

Parameters

block

the suspending function to be executed safely

Throws

if the coroutine is cancelled during the execution of block